package com.example.mqtt.common.response;

import lombok.Data;

import java.io.Serializable;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/3/29 22:47
 **/


@Data
public class Response<T> implements Serializable {
    private int code;
    private String msg;
    private T data;

    public static <T> Response<T> success(T data) {
        Response<T> response = new Response<>();
        response.setCode(200);
        response.setMsg("success");
        response.setData(data);
        return response;
    }

    public static <T> Response<T> error(int code, String msg) {
        Response<T> response = new Response<>();
        response.setCode(code);
        response.setMsg(msg);
        return response;
    }

    public static <T> Response<T> error(String msg) {
        return error(500, msg);
    }
}